import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import store from '@/store'
Vue.use(VueRouter)


let originPush = VueRouter.prototype.push
VueRouter.prototype.push = function(location,resolve,reject){ 
  if(resolve === undefined && reject===undefined){ 
    return originPush.call(this,location).catch(()=>{})
  }else{
    return originPush.call(this,location,resolve,reject)
  }
}

let originReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function(location,resolve,reject){ 
  if(resolve === undefined && reject===undefined){ 
    return originReplace.call(this,location).catch(()=>{})
  }else{ 
    return originReplace.call(this,location,resolve,reject)
  }
}

const router = new VueRouter({
  routes,
  // 路由组建跳转时 保持滚动条在最顶端
  scrollBehavior () {
    return { y: 0 }
  }
 
})





export default router